
package org.sunspotworld.demo;


public class PitchMatrix extends DecisionMatrix
{
    private static final int size = 12;
    private int[][] cds;

    public PitchMatrix()
    {
        super(size);
        initializeRoleMatrix();
        m_lowestValence = new float[size][size];
        m_highestValence = new float[size][size];
        m_lowestArousal = new float[size][size];
        m_highestArousal = new float[size][size];
        initializeAVMatrices(4);
    }
    
    public void initializeAVMatrices(int cord)
    {

        m_lowestValence = new float[][]{{1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1},
                                         {1, 5, 1, 5, 1, 1, 5, 1, 5, 1, 5, 1}};
                /*new float[][]{
                //W       B       W      B      W      W      B      W      B      W      B      W
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f}
                                     };*/

        m_highestValence = new float[][]{{5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5},
                                         {5, 1, 5, 1, 5, 5, 1, 5, 1, 5, 1, 5}};
        /*new float[][]{
                //W       B       W      B      W      W      B      W      B      W      B      W
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f}
                                     };*/
        //m_cords = new float[][][];
        //E,Em,E7,EM7,B7,A,A7,Am,Am7,D,D7,Dm,Dm7,C,C7,CM7,G,G7
                                 //0  1  2  3  4  5  6   7  8   9  10  11
                                 //C  C# D  D# E  F  F#  G  G#  A  Bb   B
        cds = new int[][]        {{0, 0, 0, 0, 1, 0, 0,  0, 1,  0, 0,   1},//E      0
                                  {0, 0, 0, 0, 1, 0, 0,  1, 0,  0, 0,   0},//Em     1
                                  {0, 0, 1, 0, 1, 0, 0,  0, 1,  0, 0,   1},//E7     2
                                  {0, 0, 0, 1, 0, 0, 1,  0, 0,  1, 0,   1},//B7     3
                                  {0, 0, 0, 1, 0, 0, 1,  0, 0,  1, 0,   1},//B7     4
                                  {0, 0, 0, 1, 0, 0, 1,  0, 0,  1, 0,   1},//B7     5
                                  {0, 1, 0, 0, 1, 0, 0,  0, 0,  1, 0,   0},//A      6
                                  {1, 0, 0, 0, 1, 0, 0,  0, 0,  1, 0,   0},//Am     7
                                  {1, 0, 0, 0, 1, 0, 0,  1, 0,  1, 0,   0},//Am7    8
                                  {0, 0, 1, 0, 0, 0, 1,  0, 0,  1, 0,   0},//D      9
                                  {0, 0, 1, 0, 0, 1, 0,  0, 0,  1, 0,   0},//Dm     10
                                  {1, 0, 1, 0, 0, 1, 0,  0, 0,  1, 0,   0},//Dm7    11
                                  {1, 0, 0, 0, 1, 0, 0,  1, 0,  0, 0,   0},//C      12
                                  {1, 0, 0, 0, 1, 0, 0,  1, 0,  0, 1,   0},//C7     13
                                  {1, 0, 0, 0, 1, 0, 0,  1, 0,  0, 0,   1},//CM7    14
                                  {0, 0, 1, 0, 0, 0, 0,  1, 0,  0, 0,   1},//G      15
                                  {0, 0, 1, 0, 0, 0, 0,  1, 0,  0, 0,   1},//G      17
                                  {0, 0, 1, 0, 0, 1, 0,  1, 0,  0, 0,   1}//G7      18
                                 };

        m_lowestArousal = new float[][]{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
        /*new float[][]{
                //W       B       W      B      W      W      B      W      B      W      B      W
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f}
                                     };*/

        m_highestArousal = new float[][]{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};
        /*new float[][]{
                //W       B       W      B      W      W      B      W      B      W      B      W
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f},
            {0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f, 0.02f, 0.13f},
            {0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f, 0.05f, 0.11f}
                                     };*/
    for(int i = 0; i < size; i++)
        {
            for(int j = 0; j < size; j++)
            {
                if(cds[cord][i]==1)
                {
                    //Favor first five major scale notes
                    m_lowestValence[i][j] = 1;
                    m_highestValence[i][j]= 1000;
                    m_lowestArousal[i][j] = 1000;
                    m_highestArousal[i][j] = 1;
                }
                else
                {
                    m_lowestValence[i][j] = 100;
                    m_highestValence[i][j]= 1;
                    m_lowestArousal[i][j] = 1;
                    m_highestArousal[i][j] = 100;
                }
            }
        }
    }


    
    private void initializeRoleMatrix()
    {
        if(SunSpotAudio.m_role == SunSpotAudio.role_harmony)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    //Favor all notes equally
                    m_roleMatrix[i][j] = 1;
                }
            }
        }
        else if(SunSpotAudio.m_role == SunSpotAudio.role_bass)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 0 || j == 2 || j == 4 || j == 5 || j == 7)
                    {
                        //Favor first five major scale notes
                        m_roleMatrix[i][j] = 10;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }
        }
        else if(SunSpotAudio.m_role == SunSpotAudio.role_percussion)
        {
            for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 0)
                    {
                        //Favor just the one note mostly
                        m_roleMatrix[i][j] = 50;
                    }
                    else if(j == 7)
                    {
                        m_roleMatrix[i][j] = 10;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = (float) 0.1;
                    }
                }
            }
        }
        else //if(SunSpotAudio.m_role == SunSpotAudio.role_melody)
        {
            m_roleMatrix = new float[][]{{10, 1, 50, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {50, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 10, 1, 50, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 50, 1, 10, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 10, 50, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 10, 1, 50, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 50, 1, 10, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 10, 1, 50, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 50, 1, 10, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 50},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 50, 1, 10},
                                         {50, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10}};
            /*m_roleMatrix = new float[][]{{10, 50, 10, 1, 1, 1, 1, 1, 1, 1, 1, 50},
                                         {50, 10, 50, 10, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 50, 10, 50, 10, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 50, 10, 50, 10, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 50, 10, 50, 10, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 50, 10, 50, 10, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 50, 10, 50, 10, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 50, 10, 50, 10, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 50, 10, 50, 10, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 50, 10, 50, 10},
                                         {10, 1, 1, 1, 1, 1, 1, 1, 1, 50, 10, 50},
                                         {50, 10, 1, 1, 1, 1, 1, 1, 1, 1, 50, 10}};*/
            /*new float[][]{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                                         {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}};*/
            /*for(int i = 0; i < m_size; i++)
            {
                for(int j = 0; j < m_size; j++)
                {
                    if(j == 0 || j == 2 || j == 4 || j == 5 || j == 7 || j == 9
                            || j == 11)
                    {
                        //Favor arpeggio notes
                        m_roleMatrix[i][j] = 5;
                    }
                    else
                    {
                        m_roleMatrix[i][j] = 1;
                    }
                }
            }*/
        }
    }
}
